const { Controller } = require('egg');

class HomeController extends Controller {

  async index() {
    const { ctx } = this;
    ctx.body = 'hi, egg';
  }

  async init() {
    const { ctx } = this;
    try {
      await this.ctx.service.home.initDataBase();
      ctx.status = 200;
      ctx.body = { code: 200, msg: '初始化成功' };
      return;
    } catch (error) {
      ctx.status = 500;
      ctx.body = { code: 500, msg: '初始化失败' };
      return;
    }
  }
}

module.exports = HomeController;
